import { get } from 'lodash-es'
import { DepositRule } from '../deposit-rule/types'

export class RoomType {
  id?: string
  hotel_id?: string
  code?: string
  name?: string
  deposit_rule_id?: string
  deposit_rule?: DepositRule
  disabled?: boolean
  sequence?: number
  created_at?: string
  updated_at?: string
  version?: number;
  [key: string]: any

  constructor(data?: RoomType) {
    this.init(data)
  }
}

RoomType.prototype.init = function init(data?: RoomType) {
  this.id = get(data, 'id')
  this.hotel_id = get(data, 'hotel_id')
  this.code = get(data, 'code', '')
  this.name = get(data, 'name', '')
  this.deposit_rule_id = get(data, 'deposit_rule_id', '')
  this.deposit_rule = get(data, 'deposit_rule')
  this.disabled = get(data, 'disabled', false)
  this.sequence = get(data, 'sequence', 1)
  this.created_at = get(data, 'created_at')
  this.updated_at = get(data, 'updated_at')
  this.version = get(data, 'version')
}
